home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / Kubuntu 8.10 / kubuntu-8.10-desktop-i386.iso / casper / filesystem.squashfs / var / lib / dpkg / info / libc6.postinst < prev    next >
Text File  |  2008-09-29  |  12KB  |  397 lines

  1. #!/bin/sh
  2. set -e
  3. export LC_ALL=C
  4.  
  5. type=$1
  6. preversion=$2
  7.  
  8. if [ "x$type" = xtriggered ]
  9. then
  10.     LDCONFIG_NOTRIGGER=y
  11.     export LDCONFIG_NOTRIGGER
  12.     echo ldconfig deferred processing now taking place
  13.     ldconfig
  14.     exit 0
  15. fi
  16.  
  17. package_name()
  18. {
  19.     echo libc6
  20. }
  21.  
  22. # Borrowed from sysvinit's postinst.
  23. #    Function like update-rc.d but simpler & faster.
  24. #    Usage: updatercd basename start|stop NN runlevel .
  25. #
  26. #    Now we use the real update-rc.d, so now this function should
  27. #    be equivalent to /usr/sbin/update-rc.d.
  28. #
  29. updatercd() {
  30.  
  31.     if [ ! -f /etc/init.d/$1 ]
  32.     then
  33.         return
  34.     fi
  35.  
  36.     if [ -x /usr/sbin/update-rc.d ]
  37.     then
  38.         update-rc.d "$@" > /dev/null
  39.         return $?
  40.     fi
  41.  
  42.     base=$1
  43.     shift
  44.     while [ "$1" != "" ]
  45.     do
  46.         if [ "$1" = stop ]
  47.         then
  48.             tlet=K
  49.         else
  50.             tlet=S
  51.         fi
  52.         lev=$2
  53.         shift 2
  54.         while [ "$1" != "." ]
  55.         do
  56.             cd /etc/rc$1.d
  57.             tmp="`echo $tlet??$base`"
  58.             case "$tmp" in
  59.                 "$tlet??$base")
  60.                     # Not present yet.
  61.                     ln -s ../init.d/$base $tlet$lev$base
  62.                     ;;
  63.                 *)
  64.                     # Already present.
  65.                     ;;
  66.             esac
  67.             shift
  68.         done
  69.         shift
  70.     done
  71. }
  72.  
  73. # element() is a helper function for file-rc:
  74. element() {
  75.     local element list IFS
  76.  
  77.     element="$1"
  78.  
  79.     [ "$2" = "in" ] && shift
  80.     list="$2"
  81.     [ "$list" = "-" ] && return 1
  82.     [ "$list" = "*" ] && return 0
  83.  
  84.     IFS=","
  85.     set -- $list
  86.     case $element in
  87.     "$1"|"$2"|"$3"|"$4"|"$5"|"$6"|"$7"|"$8"|"$9")
  88.         return 0
  89.     esac
  90.     return 1
  91. }
  92.  
  93. # filerc (runlevel, service) returns /etc/init.d/service, if service is
  94. # running in $runlevel:
  95. filerc() {
  96.     local runlevel basename
  97.     runlevel=$1
  98.     basename=$2
  99.     while read LINE
  100.     do
  101.     case $LINE in
  102.         \#*|"") continue
  103.     esac
  104.  
  105.     set -- $LINE
  106.     SORT_NO="$1"; STOP="$2"; START="$3"; CMD="$4"
  107.     [ "$CMD" = "/etc/init.d/$basename" ] || continue
  108.  
  109.     if element "$runlevel" in "$START" || element "S" in "$START"
  110.     then
  111.         echo "/etc/init.d/$basename"
  112.         return 0
  113.     fi
  114.     done < /etc/runlevel.conf
  115.     echo ""
  116. }
  117.  
  118. checkpkgver () {
  119.     local status pkg
  120.     pkg=$1
  121.     status=$(dpkg -s $pkg 2>/dev/null | grep ^Status: | sed -e 's/^Status: \(.*\) \(.*\) \(.*\)/\3/g')
  122.     if [ -n "$status" ] && [ "$status" != "not-installed" ] && [ "$status" != "config-files" ]; then
  123.     echo $(dpkg -s $pkg 2>/dev/null | grep ^Version: | sed -e 's/^Version: *//');
  124.     fi
  125. }
  126.  
  127. if [ "$type" = "configure" ]
  128. then
  129.     # Add support for /etc/ld.so.conf.d
  130.     if [ -e /etc/ld.so.conf ]; then
  131.         [ -z "$(tail -n 1 /etc/ld.so.conf)" ] || echo >> /etc/ld.so.conf
  132.     else
  133.         touch /etc/ld.so.conf
  134.     fi
  135.     if ! grep -q '^include /etc/ld.so.conf.d/.*\.conf$' /etc/ld.so.conf ; then
  136.         echo 'include /etc/ld.so.conf.d/*.conf' >> /etc/ld.so.conf
  137.     fi
  138.  
  139.     # We don't use a registry anymore, remove the old file
  140.     rm -f /etc/ld.so.hwcappkgs
  141.  
  142.     # /etc/ld.so.nohwcap code: NOHWCAP
  143.     # Handle upgrades when libc-opt package has been installed.
  144.     # When a /etc/ld.so.nohwcap file exists, ld.so only use libraries
  145.     # from /lib, and ignore all optimised libraries. This file is
  146.     # inconditionaly created in the preinst script of libc.
  147.  
  148.     # Get the list of optimized packages for a given architecture
  149.     # Before removing a package from this list, make sure it appears
  150.     # in the Conflicts: line of libc.
  151.     case $(dpkg --print-architecture) in
  152.         alpha)
  153.             hwcappkgs="libc6-alphaev67"
  154.             ;;
  155.         i386)
  156.             hwcappkgs="libc6-i686 libc6-xen"
  157.             ;;
  158.         kfreebsd-i386)
  159.             hwcappkgs="libc0.1-i686"
  160.             ;;
  161.         sparc)
  162.             hwcappkgs="libc6-sparcv9 libc6-sparcv9b libc6-sparcv9v libc6-sparcv9v2 libc6-sparc64b libc6-sparc64v libc6-sparc64v2"
  163.             ;;
  164.     esac
  165.  
  166.     # We check the version between the current installed libc and
  167.     # all optimized packages (on architectures where such packages
  168.     # exists).
  169.     all_upgraded=yes
  170.     if [ -n "$hwcappkgs" ]; then
  171.         for pkg in $hwcappkgs ; do
  172.             ver=$(dpkg -l $pkg 2>/dev/null | sed -e '/^i/!d;' -e "s/^i.\s\+$pkg\s\+//;s/\s.*//g")
  173.             if [ -n "$ver" ] && [ "$ver" != "2.8~20080505-0ubuntu7" ]; then
  174.                 all_upgraded=no
  175.             fi
  176.         done
  177.     fi
  178.  
  179.     # If the versions of all optimized packages are the same as the libc
  180.     # one, we could remove /etc/ld.so.nohwcap. Otherwise, it will be removed
  181.     # when all optimized packages are upgraded or removed.
  182.     if [ "$all_upgraded" = yes ] ; then
  183.         rm -f /etc/ld.so.nohwcap
  184.     fi
  185.  
  186.     # Load debconf module if available
  187.     if [ -f /usr/share/debconf/confmodule ] ; then
  188.     . /usr/share/debconf/confmodule
  189.     fi
  190.  
  191.     if [ -n "$preversion" ]; then
  192.     if [ ! -d /var/mail ] && [ ! -L /var/mail ]; then
  193.         ln -sf spool/mail /var/mail
  194.     fi
  195.     if dpkg --compare-versions "$preversion" lt 2.6-1; then
  196.         check="apache2-common apache apache-ssl apache-perl autofs at"
  197.         check="$check boa cucipop courier-authdaemon cron cupsys exim"
  198.         check="$check exim4-base dovecot-common cucipop lprng lpr"
  199.         check="$check lpr-ppd mysql-server nis openbsd-inetd"
  200.         check="$check openldapd postfix postfix-tls rsync samba"
  201.         check="$check sasl2-bin slapd smail sendmail snmpd ssh"
  202.         check="$check spamassassin vsftpd wu-ftpd wu-ftpd-academ wwwoffle"
  203.         check="$check webmin dropbear"
  204.         # NSS services check: NSS_CHECK
  205.         echo -n "Checking for services that may need to be restarted..."
  206.         # Only get the ones that are installed, and configured
  207.         check=$(dpkg -s $check 2> /dev/null | egrep '^Package:|^Status:' | awk '{if ($1 ~ /^Package:/) { package=$2 } else if ($0 ~ /^Status: .* installed$/) { print package }}')
  208.         # some init scripts don't match the package names
  209.         check=$(echo $check | \
  210.                 sed -e's/\bapache2-common\b/apache2/g' \
  211.                     -e's/\bat\b/atd/g' \
  212.                     -e's/\bdovecot-common\b/dovecot/g' \
  213.                     -e's/\bexim4-base\b/exim4/g' \
  214.                     -e's/\blpr\b/lpd/g' \
  215.                     -e's/\blpr-ppd\b/lpd-ppd/g' \
  216.                     -e's/\bsasl2-bin\b/saslauthd/g' \
  217.         )
  218.         echo
  219.         echo "Checking init scripts..."
  220.         rl=$(runlevel | sed 's/.*\ //')
  221.         for service in $check; do
  222.             if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
  223.                 idl=$(ls /etc/init.d/${service} 2> /dev/null | head -n 1)
  224.                 if [ -n "$idl" ] && [ -x $idl ]; then
  225.                     services="$service $services"
  226.                 else
  227.                     echo "WARNING: init script for $service not found."
  228.                 fi
  229.             else
  230.                 if [ -f /usr/share/file-rc/rc ] || [ -f /usr/lib/file-rc/rc ] && [ -f /etc/runlevel.conf ]; then
  231.                     idl=$(filerc $rl $service)
  232.                 else
  233.                     idl=$(ls /etc/rc${rl}.d/S??${service} 2> /dev/null | head -1)
  234.                 fi
  235.                 if [ -n "$idl" ] && [ -x $idl ]; then
  236.                     services="$service $services"
  237.                 fi
  238.             fi
  239.         done
  240.         if [ -n "$services" ]; then
  241.  
  242.             if [ -f /usr/share/debconf/confmodule ] ; then
  243.             db_version 2.0
  244.             db_reset glibc/restart-services
  245.             db_set glibc/restart-services "$services"
  246.             if [ "$RELEASE_UPGRADE_MODE" = desktop ]; then
  247.             db_input medium glibc/restart-services || true
  248.             else
  249.             db_input critical glibc/restart-services || true
  250.             fi
  251.             db_go || true
  252.             db_get glibc/restart-services
  253.             if [ "x$RET" != "x" ]
  254.             then
  255.                 services="$RET"
  256.             else
  257.                 services=""
  258.             fi
  259.         else
  260.             echo
  261.             echo "Name Service Switch update in the C Library: post-installation question."
  262.             echo
  263.             echo "Running services and programs that are using NSS need to be restarted,"
  264.             echo "otherwise they might not be able to do lookup or authentication any more"
  265.             echo "(for services such as ssh, this can affect your ability to login)."
  266.             echo "Note: restarting sshd/telnetd should not affect any existing connections."
  267.             echo
  268.             echo "The services detected are: "
  269.             echo "        $services"
  270.             echo
  271.             echo "If other services have begun to fail mysteriously after this upgrade, it is"
  272.             echo "probably necessary to restart them too.  We recommend that you reboot your"
  273.             echo "machine after the upgrade to avoid NSS-related troubles."
  274.             echo
  275.             frontend=`echo "$DEBIAN_FRONTEND" | tr '[:upper:]' '[:lower:]'`
  276.             if [ "$frontend" = noninteractive ]; then
  277.                 echo "Non-interactive mode, restarting services"
  278.                 answer=yes
  279.             else
  280.                 echo -n "Do you wish to restart services? [Y/n] "
  281.                 read answer
  282.                 case $answer in
  283.                 N*|n*) services="" ;;
  284.                 *) ;;
  285.                 esac
  286.             fi
  287.         fi
  288.         echo
  289.         if [ "$services" != "" ]; then
  290.             echo "Restarting services possibly affected by the upgrade:"
  291.             failed=""
  292.             for service in $services; do
  293.                 if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
  294.                 idl="invoke-rc.d ${service}"
  295.             elif [ -f /usr/share/file-rc/rc ] || [ -f /usr/lib/file-rc/rc ] && [ -f /etc/runlevel.conf ]; then
  296.                 idl=$(filerc $rl $service)
  297.             else
  298.                 idl=$(ls /etc/rc${rl}.d/S??${service} 2> /dev/null | head -1)
  299.             fi
  300.             echo -n "  $service: stopping..."
  301.             $idl stop > /dev/null 2>&1 || true
  302.             sleep 2
  303.             echo -n "starting..."
  304.             if $idl start > /dev/null 2>&1; then
  305.                 echo "done."
  306.             else
  307.                 echo "FAILED! ($?)"
  308.                 failed="$service $failed"
  309.             fi
  310.             done
  311.             echo
  312.             if [ -n "$failed" ]; then
  313.                 if [ -f /usr/share/debconf/confmodule ] ; then
  314.                     db_fset glibc/restart-failed seen false
  315.                 db_subst glibc/restart-failed services "$failed"
  316.                 if [ "$RELEASE_UPGRADE_MODE" = desktop ]; then
  317.                 db_input medium glibc/restart-failed || true
  318.                 else
  319.                 db_input critical glibc/restart-failed || true
  320.                 fi
  321.                 db_go || true
  322.             else
  323.                 echo "The following services failed to start: $failed"
  324.                 echo
  325.                 echo "You will need to start these manually by running \`/etc/init.d/<service> start'"
  326.                 echo "If the service still fails to start, you may need to file a bug on"
  327.                 echo "$(package_name) or the service involved."
  328.                 frontend=`echo "$DEBIAN_FRONTEND" | tr '[:upper:]' '[:lower:]'`
  329.                 if [ "$frontend" != noninteractive ]; then
  330.                     echo
  331.                     echo -n "Press ENTER to continue: "
  332.                     read foo
  333.                 fi
  334.             fi
  335.             else
  336.             echo "Services restarted successfully."
  337.                     fi
  338.         fi
  339.                 # Shut down the frontend, to make sure none of the
  340.         # restarted services keep a connection open to it
  341.             if [ -f /usr/share/debconf/confmodule ] ; then
  342.             db_stop
  343.         fi
  344.         else
  345.         echo "Nothing to restart."
  346.         fi
  347.     fi # end upgrading and $preversion lt 2.6-1
  348.     fi # Upgrading
  349.  
  350.     # Generate cache file /usr/lib/gconv/gconv-modules.cache
  351.     iconvconfig || true
  352.  
  353.     # Ubuntu change.  Do not do kernel version detection at startup.
  354.     update-rc.d -f glibc.sh remove >/dev/null 2>&1
  355.  
  356. fi
  357.  
  358. if [ "`uname -s`" = Linux ]; then
  359. #
  360. #       Upgrade init if possible. There was a bug in all versions
  361. #       up to and including 2.75-4, which didn't affect i386 but
  362. #       did affect most other architectures.
  363. #
  364. sysvinitver="`dpkg -s sysvinit 2>/dev/null | grep ^Version: | sed -e 's/^Version: *//'`"
  365. case "`uname -m`" in
  366.         i?86)
  367.                 badsysvinitver="2.[0-6]*|2.7[0-3]*"
  368.                 ;;
  369.         *)
  370.                 badsysvinitver="2.[0-6]*|2.7[0-4]*|2.75-*"
  371.                 ;;
  372. esac
  373. # Black magic. If we are in a chroot, then /proc/1/exe will not resolve to
  374. # a file (will return EPERM). This keeps us from breaking things in
  375. # debootstrap, and the like.
  376. case "$sysvinitver" in
  377.         $badsysvinitver)
  378.                 ;;
  379.         *)
  380.         if [ "$(stat -c %d/%i /)" = "$(stat -Lc %d/%i /proc/1/root 2>/dev/null)" ]; then
  381.             # the devicenumber/inode pair of / is the same as that of /sbin/init's
  382.             # root, so we're *not* in a chroot
  383.             (init u ; sleep 1)
  384.         fi
  385.         ;;
  386. esac
  387. fi
  388.  
  389. # Automatically added by dh_makeshlibs
  390. if [ "$1" = "configure" ]; then
  391.     ldconfig
  392. fi
  393. # End automatically added section
  394.  
  395.  
  396. exit 0
  397.